export const state = () => ({
  userInfo: {}
})

export const mutations = {
  login(state, userInfo) {
    state.userInfo = userInfo;
  },
  // 退出
  logOut(state) {
    state.userInfo = {};
  }
}

// 如果想要异步的方式来修改 state的数据  一般是使用acions
export const actions = {
  async login({ commit }, loginForm) {
    const res = await this.$axios.post("/accounts/login", loginForm);
    commit("login", res);
  }
}